package com.ml.mall.schedule;

import com.ml.mall.job.IBaseJobService;
import com.ml.mall.job.pojo.ScheduleJobDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @author liusongbo
 */
@Slf4j
@Component
public class TScheduler {
    @Autowired
    private IBaseJobService baseJobService;


    @PostConstruct
    public void initCleanRedisCache() {
        System.out.println(1);
        ScheduleJobDTO scheduleJobDTO = new ScheduleJobDTO();
        scheduleJobDTO.setJobName("CleanRedisCache");
        scheduleJobDTO.setJobGroup("CleanRedisCacheGroup");
        scheduleJobDTO.setCronJob(true);
        scheduleJobDTO.setCronExpression("*/5 * * * * ?");
        scheduleJobDTO.setDesc("清除redis缓存数据");
        // 这里要指定具体的执行job
        scheduleJobDTO.setJobClass("com.ml.mall.schedule.TestSche");
        baseJobService.addJob(scheduleJobDTO, true);
    }
}
